//
//  SERefresh.swift
//  SmartEyeForDoctor
//
//  Created by QDSG on 2021/4/20.
//

import MJRefresh

extension UIScrollView {
    var se_header: MJRefreshHeader? {
        get { mj_header }
        set { mj_header = newValue }
    }
    
    var se_footer: MJRefreshFooter? {
        get { mj_footer }
        set { mj_footer = newValue }
    }
    
    func endHeaderRefreshing() {
        se_header?.endRefreshing()
    }
    
    func endFooterRefreshing(hasMore: Bool = true) {
        if hasMore == false {
            se_footer?.isAutomaticallyChangeAlpha = false
            se_footer?.endRefreshingWithNoMoreData()
        } else {
            se_footer?.isAutomaticallyChangeAlpha = true
            se_footer?.endRefreshing()
        }
    }
}

class SERefreshHeader: MJRefreshNormalHeader {}

class SERefreshAutoHeader: MJRefreshHeader {}

class SERefreshFooter: MJRefreshBackNormalFooter {
    override func prepare() {
        super.prepare()
        isAutomaticallyChangeAlpha = true
    }
}

class SERefreshAutoFooter: MJRefreshAutoFooter {}
